# -*- coding: utf-8 -*-
# @Time    : 2019/2/25 9:34
# @Author  : yueconger
# @File    : write2excel.py
import xlwt
import json
from openpyxl import Workbook

path = r'E:\bmsoft\ruanming\yuecong\FggSpider\刑事犯罪_4.json'
with open(path, 'r', encoding='utf-8') as f:
    contents = f.read()
content_list = json.loads(contents)
print(len(content_list))
item_list = []
item_list.append(['question', 'answer'])
for content in content_list:
    question = content['question']
    print(question)
    answer = content['answer']
    item_list.append([question, answer])
wb = Workbook()
# 创建一个sheet
ws = wb.create_sheet()
# print('条数:', len(item_list))
for item in item_list:
    ws.append(item)
wb.save("刑事问答数据_增.xlsx")
